package com.znf4.controller.bank;
/*package com.znf4.platform.controller.bank;

import java.util.Date;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.znf4.platform.bank.entity.RpBankChannel;
import com.znf4.platform.bank.enums.BankChannelTypeEnum;
import com.znf4.platform.bank.enums.BankSettTypeEnum;
import com.znf4.platform.bank.enums.BankWayEnum;
import com.znf4.platform.bank.service.RpBankChannelService;
import com.znf4.platform.common.core.dwz.DWZ;
import com.znf4.platform.common.core.dwz.DwzAjax;
import com.znf4.platform.common.core.enums.BankChannelCodeEnum;
import com.znf4.platform.common.core.enums.CalculateTypeEnum;
import com.znf4.platform.common.core.enums.PublicStatusEnum;
import com.znf4.platform.common.core.enums.RateTypeEnum;
import com.znf4.platform.common.core.page.PageBean;
import com.znf4.platform.common.core.page.PageParam;
import com.znf4.platform.common.core.utils.StringUtil;
import com.znf4.platform.user.exception.PayBizException;

*//**
 * 银行渠道
 *//*
@Controller
@RequestMapping("/bankChannel")
public class BankChannelController {
	private static final Log log = LogFactory.getLog(BankChannelController.class);
	@Autowired
	private RpBankChannelService rpBankChannelService;

	*//**
	 * 函数功能说明 ： 查询银行渠道信息
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequestMapping(value = "/list", method = { RequestMethod.POST, RequestMethod.GET })
	public String list(RpBankChannel rpBankChannel, PageParam pageParam, Model model) {
		try {
			model.addAttribute("pageBean", rpBankChannelService.listPage(pageParam, rpBankChannel));
		} catch (Exception e) {
			log.error(e);
			DwzAjax dwz = new DwzAjax();
			dwz.setStatusCode(DWZ.ERROR);
			dwz.setMessage("银行渠道信息分页列表异常，请通知系统管理员！");
			model.addAttribute("dwz", dwz);
			return "common/ajaxDone";
		}
		return "bankChannel/list";
	}

	*//**
	 * 函数功能说明 ：跳转添加渠道页面
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequiresPermissions("bank:bankChannel:add")
	@RequestMapping(value = "/addUI", method = RequestMethod.GET)
	public String addUI(Model model) {
		model.addAttribute("RateTypeEnums", RateTypeEnum.toList());
		model.addAttribute("BankChannelTypeEnums", BankChannelTypeEnum.toList());
		model.addAttribute("BankSettTypeEnums", BankSettTypeEnum.toList());
		model.addAttribute("BankWayEnums", BankWayEnum.toList());
		model.addAttribute("BankChannelCodeEnums", BankChannelCodeEnum.toList());
		model.addAttribute("CalculateTypeEnums", CalculateTypeEnum.toList());
		return "bankChannel/add";
	}

	*//**
	 * 函数功能说明 ： 添加渠道
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequiresPermissions("bank:bankChannel:add")
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public String add(Model model, RpBankChannel rpBankChannel, DwzAjax dwz) {
		RpBankChannel bankChannel = rpBankChannelService.getByBankChannelCode(rpBankChannel.getBankChannelCode());
		if (bankChannel != null) {
			dwz.setStatusCode(DWZ.ERROR);
			dwz.setMessage("银行渠道已存在");
			model.addAttribute("dwz", dwz);
			return "common/ajaxDone";
		}

		if (RateTypeEnum.PERCENT.name().equals(rpBankChannel.getRateType())) {
			if (rpBankChannel.getLowestRate() == null) {
				throw new PayBizException(PayBizException.LOWEST_RATE_ERROR, "最低手续费不能为空");
			}

			if (rpBankChannel.getLowestRate() < 0) {
				throw new PayBizException(PayBizException.LOWEST_RATE_ERROR, "最低手续费不能小于0");
			}

		} else {
			rpBankChannel.setLowestRate(rpBankChannel.getBankRate().doubleValue());
		}

		try {

			String settType = BankChannelCodeEnum.getEnum(rpBankChannel.getBankChannelCode()).getBankSettType();
			if (BankSettTypeEnum.T0.name().equals(settType)) {
				if (rpBankChannel.getWeekendBankRate() == null) {
					rpBankChannel.setWeekendBankRate(rpBankChannel.getBankRate());
				}
			}else{//非T0状态 周末费率与工作日一样
				rpBankChannel.setWeekendBankRate(rpBankChannel.getBankRate());
			}

			rpBankChannel.setStatus(PublicStatusEnum.ACTIVE.name());
			rpBankChannel.setBankWayName(BankWayEnum.getEnum(rpBankChannel.getBankWayCode()).getDesc());
			rpBankChannel.setLaunchType(BankChannelCodeEnum.getEnum(rpBankChannel.getBankChannelCode()).getBankLaunchTypeEnum().name());
			rpBankChannel.setBankChannelName(BankChannelCodeEnum.getEnum(rpBankChannel.getBankChannelCode()).getDesc());
			rpBankChannel.setSettType(BankChannelCodeEnum.getEnum(rpBankChannel.getBankChannelCode()).getBankSettType());
			rpBankChannelService.saveData(rpBankChannel);
		} catch (Exception e) {
			log.error(e);
			dwz.setStatusCode(DWZ.ERROR);
			dwz.setMessage("添加银行渠道，请通知系统管理员！");
			model.addAttribute("dwz", dwz);
			return "common/ajaxDone";
		}
		dwz.setStatusCode(DWZ.SUCCESS);
		dwz.setMessage(DWZ.SUCCESS_MSG);
		model.addAttribute("dwz", dwz);
		return DWZ.AJAX_DONE;
	}

	*//**
	 * 函数功能说明 ：跳转编辑
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequiresPermissions("bank:bankChannel:edit")
	@RequestMapping(value = "/editUI", method = RequestMethod.GET)
	public String editUI(Model model, @RequestParam("id") String id) {
		RpBankChannel rpBankChannel = rpBankChannelService.getDataById(id);
		model.addAttribute("rpBankChannel", rpBankChannel);
		model.addAttribute("RateTypeEnums", RateTypeEnum.toList());
		model.addAttribute("BankChannelTypeEnums", BankChannelTypeEnum.toList());
		model.addAttribute("BankSettTypeEnums", BankSettTypeEnum.toList());
		model.addAttribute("BankWayEnums", BankWayEnum.toList());
		model.addAttribute("BankChannelCodeEnums", BankChannelCodeEnum.toList());
		model.addAttribute("CalculateTypeEnums", CalculateTypeEnum.toList());
		return "bankChannel/edit";
	}

	*//**
	 * 函数功能说明 ： 更新
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequiresPermissions("bank:bankChannel:edit")
	@RequestMapping(value = "/edit", method = RequestMethod.POST)
	public String edit(Model model, RpBankChannel rpBankChannel, DwzAjax dwz) {

		if (RateTypeEnum.PERCENT.name().equals(rpBankChannel.getRateType())) {
			if (rpBankChannel.getLowestRate() == null) {
				throw new PayBizException(PayBizException.LOWEST_RATE_ERROR, "最低手续费不能为空");
			}

			if (rpBankChannel.getLowestRate() < 0) {
				throw new PayBizException(PayBizException.LOWEST_RATE_ERROR, "最低手续费不能小于0");
			}

		} else {// 如果是按笔收,最低手续费就是每笔手续费
			rpBankChannel.setLowestRate(rpBankChannel.getBankRate().doubleValue());
		}

		try {
			RpBankChannel rpBankChannelOld = rpBankChannelService.getDataById(rpBankChannel.getId());

			rpBankChannelOld.setBankWayCode(rpBankChannel.getBankWayCode());
			rpBankChannelOld.setBankWayName(BankWayEnum.getEnum(rpBankChannel.getBankWayCode()).getDesc());

			rpBankChannelOld.setEditTime(new Date());
			rpBankChannelOld.setBankRate(rpBankChannel.getBankRate());
			rpBankChannelOld.setRemark(rpBankChannel.getRemark());
			rpBankChannelOld.setRateType(rpBankChannel.getRateType());
			rpBankChannelOld.setSettType(BankChannelCodeEnum.getEnum(rpBankChannel.getBankChannelCode()).getBankSettType());
			if (BankSettTypeEnum.T0.name().equals(BankChannelCodeEnum.getEnum(rpBankChannel.getBankChannelCode()).getBankSettType())){
				rpBankChannelOld.setWeekendBankRate(rpBankChannel.getWeekendBankRate());
			}else{//非T0的周末费率,跟工作日费率相同
				rpBankChannelOld.setWeekendBankRate(rpBankChannel.getBankRate());
			}
			rpBankChannelOld.setBankChannelType(rpBankChannel.getBankChannelType());
			rpBankChannelOld.setBankChannelName(BankChannelCodeEnum.getEnum(rpBankChannel.getBankChannelCode()).getDesc());
			rpBankChannelOld.setLowestRate(rpBankChannel.getLowestRate());
			rpBankChannelOld.setCalculateType(rpBankChannel.getCalculateType());
			rpBankChannelService.updateData(rpBankChannelOld);

		} catch (Exception e) {
			log.error(e);
			dwz.setStatusCode(DWZ.ERROR);
			dwz.setMessage("添加银行渠道，请通知系统管理员！");
			model.addAttribute("dwz", dwz);
			return "common/ajaxDone";
		}
		dwz.setStatusCode(DWZ.SUCCESS);
		dwz.setMessage(DWZ.SUCCESS_MSG);
		model.addAttribute("dwz", dwz);
		return DWZ.AJAX_DONE;
	}

	*//**
	 * 函数功能说明 ： 查找带回
	 * 
	 * @参数： @return @return String @throws
	 *//*
	@RequestMapping(value = "/lookupList", method = { RequestMethod.POST, RequestMethod.GET })
	public String lookupList(RpBankChannel rpBankChannel, PageParam pageParam, Model model, String isAnotherPay) {
		// 查询已生效数据
		if(!StringUtil.isEmpty(isAnotherPay)){//查询代付数据
			rpBankChannel.setBankChannelType(BankChannelTypeEnum.ANOTHER_PAY.name());
		}
		rpBankChannel.setStatus(PublicStatusEnum.ACTIVE.name());
		PageBean pageBean = rpBankChannelService.listPage(pageParam, rpBankChannel);
		model.addAttribute("pageBean", pageBean);
		return "bankChannel/lookupList";
	}

	*//**
	 * 函数功能说明 ：根据支付方式获取支付类型
	 * 
	 * @参数： @return
	 * @return String
	 * @throws
	 *//*
	@RequestMapping(value = "/getBankChannel", method = RequestMethod.GET)
	@ResponseBody
	public List getBankChannel(@RequestParam("bankWayCode") String bankWayCode) {
		return BankChannelCodeEnum.getBankChannelListByPayWayCode(bankWayCode);
	}

}
*/